@extends('admin.layout')
@section('title', '网站 - 通讯服务器')
@section('content')
        <!-- 面包屑导航 -->
        <div class="row wrapper border-bottom white-bg page-heading" style="height: 40px;">
            <div class="col-sm-12">
                <ol class="breadcrumb" style="padding-top: 12px;">
                    <li>
                        <a href="index_v1.html">主页</a>
                    </li>
                    <li>
                        <strong>通讯服务器</strong>
                    </li>
                </ol>
            </div>
        </div>

        <div class="wrapper wrapper-content animated fadeInRight">
            <div class="row">
                <div class="col-sm-12">
                    <div class="ibox float-e-margins">
                        <div class="ibox-title">
                            <h5>通讯服务器 <small></small></h5>
                        </div>
                        <div class="ibox-content">
                            <div class="row">
                                 <form role="form" id="form">
                                    <div class="col-sm-12">

                                        <div class="form-group col-sm-12">
                                            <label>服务器IP</label>
                                            <input type="text" name="ip" value="{{$data['ip']}}" placeholder="请输入通讯服务器IP地址" class="form-control">
                                        </div>

                                        <div class="form-group col-sm-12">
                                            <label>自定义通讯端口</label>
                                            <input type="text" name="dk" value="{{$data['dk']}}" placeholder="请输入通讯服务器端口" class="form-control">
                                        </div>

                                        <div>
                                            <button class="btn btn-sm btn-info pull-right m-t-n-xs"
                                                type="button" id="hold"><strong>立即保存</strong>
                                            </button>
                                        </div>
                                    </div>

                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <script>
            $('#hold').click(function () {
                fd = new FormData(document.getElementById('form'));
                $.ajax({
                    url: 'server',
                    type: 'POST',
                    timeout: 3000,
                    dataType: 'JSON',
                    contentType: 'application/x-www-form-urlencoded;charset=utf-8',
                    data: fd,
                    contentType: false,//不设置内容类型
                    processData: false,//不处理数据
                    success: function (data) {
                        if (data.code == 200) {
                            toastr.success(data.msg);
                        } else {
                            toastr.warning(data.msg);
                        }
                    },
                    error: function (XMLResponse) {
                        //异常捕获
                        toastr.error(XMLResponse.responseText);
                    }
                });
            });
            
        </script>
@endsection